<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <!-- 统计字符串中某个字符出现的次数 -->
</head>
<body>
  <script>
  /*
    str { String } 完整字符串
    tatget { String } 目标对象，要查找的字符串
  */
function searchStrEach(str, target) {
   let sum = 0
   for (let key of str) {
      if (key == target) {
         sum ++
      }
   }
   return sum;
 }
 console.log(searchStrEach('sdsasads', 'd'));
 let str = 'sdsasads'
 console.log(str.split('d').length - 1);
  </script>
</body>
</html>